package Chapter7_MultiplexingClass;

/**
 * Date: 2019/2/18
 * Time: 18:06
 * User: Driss.
 *
 * 7.3 代理 小结  练习11 修改Delegation类，让它使用代理
 */
public class DetergentDelegation {
    private Cleanser cleanser = new Cleanser();


    public void append(String a){
        cleanser.append(a);
    }

    public void dilute(){
        cleanser.dilute();
    }

    public void apply(){
        cleanser.apply();
    }

    public void scrub(){
        append(" Detergent.scrub()");
        cleanser.scrub();
    }

    public void foam(){
        append(" foam()");
    }

    public String toString(){
        return cleanser.toString();
    }

    public static void main(String[] args) {
        Detergent detergentDelegation = new Detergent();
        detergentDelegation.dilute();
        detergentDelegation.apply();
        detergentDelegation.scrub();
        detergentDelegation.foam();

        System.out.println(detergentDelegation);
        System.out.println("Testing base class:");
        Cleanser.main(args);
    }

}
